package org.gwtEss.gwtExtensions;

import org.gwtEss.other.WidgetResizer;

import com.google.gwt.event.dom.client.HasMouseDownHandlers;
import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Widget;

public class ResizableDialogBox extends DialogBox implements HasMouseDownHandlers{
	private Widget w;
	WidgetResizer rd;
	public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
		return addDomHandler(handler, MouseDownEvent.getType());
	}
	@Override
	public void setWidget(Widget w) {
		this.w = w; 
		super.setWidget(w);
		DeferredCommand.addCommand(new Command() {
			
			@Override
			public void execute() {
				rd.setWidget((Widget)ResizableDialogBox.this);
			}
		});
	}
}
